package com.sjn.common.config;

import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @Author: sjn
 * @Data: 2025/6/16 17:35
 */
@Configuration
@Slf4j
public class CommonWebMvcConfig implements WebMvcConfigurer {
// WebMvcConfigurationSupport 会禁用 Spring Boot 的默认 MVC 自动配置

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        log.info("统一静态资源映射配置。");
        registry.addResourceHandler("doc.html")
                .addResourceLocations("classpath:/META-INF/resources/");

        registry.addResourceHandler("swagger-ui.html")
                .addResourceLocations("classpath:/META-INF/resources/");
        registry.addResourceHandler("/webjars/**")
                .addResourceLocations("classpath:/META-INF/resources/webjars/");
    }

//    @Bean
//    public OpenAPI customOpenAPI() {
//        return new OpenAPI()
//                .info(new Info()
//                        .title("DEMO-COMMON API文档")
//                        .version("v1.0.0")
//                        .description("这是一个基于Spring Boot 3和OpenAPI 3的RESTful API文档")
//                        .termsOfService("http://example.com/terms/")
//                        .license(new License().name("Apache 2.0").url("http://springdoc.org")));
//    }

}
